package galaxy.app.system;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import com.alibaba.fastjson.JSONObject;

import galaxy.app.common.NodeInfo;
import galaxy.kernel.component.AbstractECSComponent;

public class ConfigComponent extends AbstractECSComponent{
    public boolean debug;

    public String rootConfigPath;
    public String envDir;
    public String[] basePackages;
    public String envName;
    public String nodeId;

    /**
     * app.json json object
     */
    public JSONObject appConfig;

    /**
     * 所有配置的服务器信息
     * key:nodeType, value:List<NodeInfo>
     */
    public Map<String, List<NodeInfo>> nodesInfo = new ConcurrentHashMap<>();

    /**
     * 当前服务器信息
     */
    public NodeInfo currentNode;

    public List<NodeInfo> getNodeInfoList(String serverType) {
        return this.nodesInfo.getOrDefault(serverType, new ArrayList<>());
    }
}
